package com.huaruan.youdi.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import com.huaruan.youdi.R;
import com.huaruan.youdi.models.HistoryModel;
import com.huaruan.youdi.utils.TimeUtils;
import com.huaruan.youdi.views.widget.easyrecyclerview.adapter.BaseViewHolder;
import com.huaruan.youdi.views.widget.easyrecyclerview.adapter.RecyclerArrayAdapter;


public class HistoryAdapter extends RecyclerArrayAdapter<HistoryModel> {
    Context context;

    public HistoryAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(parent);
    }

    class ViewHolder extends BaseViewHolder<HistoryModel> {
        TextView tv_code;
        TextView tv_time;
        TextView tv_send_name;
        TextView tv_send_phone;
        TextView tv_send_address;
        TextView tv_receive_name;
        TextView tv_receive_phone;
        TextView tv_receive_address;
        TextView tv_date;
        TextView tv_price;

        public ViewHolder(ViewGroup itemView) {
            super(itemView, R.layout.item_history);
            this.tv_code = $(R.id.tv_code);
            this.tv_time = $(R.id.tv_time);
            this.tv_send_name = $(R.id.tv_send_name);
            this.tv_send_phone = $(R.id.tv_send_phone);
            this.tv_send_address = $(R.id.tv_send_address);
            this.tv_receive_name = $(R.id.tv_receive_name);
            this.tv_receive_phone = $(R.id.tv_receive_phone);
            this.tv_receive_address = $(R.id.tv_receive_address);
            this.tv_date = $(R.id.tv_date);
            this.tv_price = $(R.id.tv_price);
        }

        @Override
        public void setData(HistoryModel model) {
            super.setData(model);
            tv_code.setText(model.tmNo);
            tv_time.setText("耗时: "+TimeUtils.getTime(model.totalTime));
            tv_send_name.setText(model.sender);
            tv_send_phone.setText(model.senderPhone);
            tv_send_address.setText(model.senderAddress);
            tv_receive_name.setText(model.receiver);
            tv_receive_phone.setText(model.receiverPhone);
            tv_receive_address.setText(model.receiverAddress);
            tv_date.setText(model.updateTime);
            tv_price.setText(model.amount);
        }
    }
}
